function _instanceof(example, classFn) {
  // 1. 参数处理
  if (typeof classFn !== "function") throw new TypeError(`Right-hand side of 'instanceof' is not callable`);
  if (example == null) return false;

  // 2. 检查方法
  // 2.1 先通过 classFn[Symbol.hasInstance](example) 方法判断
  var hasInstance = classFn[Symbol.hasInstance]
  if (typeof hasInstance === 'function') {
    return hasInstance.call(classFn, example)
  }
  // 2.2 如果不存在上面的方法，则通过 example.__proto__ 是否能找到 classFn.prototype 来判断
  var prototype = classFn.prototype,
      proto = Object.getPrototypeOf(example)

  while(proto) {
    if (proto === prototype) return true
    proto = Object.getPrototypeOf(proto)
  }

  return false

}

console.log("原生instanceof", p1 instanceof Person1);
console.log("原生instanceof", p4 instanceof Person1);
console.log("原生instanceof", p2 instanceof Person1);
console.log("原生instanceof", p5 instanceof Person1);
console.log("手动实现instanceof", _instanceof(p1,Person1));
console.log("手动实现instanceof", _instanceof(p4,Person1));
console.log("手动实现instanceof", _instanceof(p2,Person1));
console.log("手动实现instanceof", _instanceof(p5,Person1));
